import http from '@/utils/http'

/**
 * @description 添加商品到购物车(适用于 [商品详情加入购物车] 以及 [购物车更新商品数量)
 * @param {Object} param: { goodsId: 商品id, count: 商品数量, blessing: 祝福语 } 
 * @returns Promise
 */
export const reqAddCart = ({ goodsId, count, ...data }) => {
    return http.get(`/cart/addToCart/${goodsId}/${count}`, data)
}

/**
 * @description 购物车列表
 * @returns Promise
 */
export const reqCartList = () => {
     return http.get(`/cart/getCartList`)
} 

/**
 * @description 更新商品选中的状态
 * @param {*} goodsId: 商品id
 * @param {*} isChecked: 更新后的状态，0 不勾选，1 勾选 
 * @returns Promise
 */
export const reqUpdateChecked = (goodsId, isChecked) => {
     return http.get(`/cart/checkCart/${goodsId}/${isChecked}`)
} 

/**
 * @description 购物车全选和全部选状态
 * @param {*} isChecked: 0 取消全选，1 全选
 * @returns Promise 
 */
export const reqCheckAllStatus = (isChecked) => {
     return http.get(`/cart/checkAllCart/${isChecked}`)
} 

/**
 * @description 删除商品
 * @param {*} goodsId: 商品id
 * @returns Promise 
 */
export const reqDelCartGoods = (goodsId) => {
    return http.get(`/cart/delete/${goodsId}`)
} 